 const {
     remote,
          BrowserWindow,Notification
 } = require('electron').remote;
 const {
     ipcRenderer
 } = require('electron');
 const fs = require('fs')


 const btn_noMenu = document.querySelector("#noMenu");
 const btn_hideClose = document.querySelector("#hideClose");
 const btn_readPackage = document.querySelector("#readPackage");
 const div_package = document.querySelector("#package");


 btn_noMenu.onclick = () => {
     let win = new BrowserWindow({
         width: 500,
         height: 300,
         title: '没有menu的窗口',
     });
     win.setMenu(null)
     win.on('close', () => {
         win = null;
     })
 }

 btn_hideClose.onclick = () => {
     let win = new BrowserWindow({
         width: 500,
         height: 300,
         // 去掉导航，关闭最大最小
         frame: false,
         resizable: false,
         useContentSize: true,
         title: '并且不能改变大小'
     });
     win.on('close', () => {
         win = null;
     })
 }

 btn_readPackage.onclick = () => {
     fs.readFile('./package.json', 'utf-8', (err, data) => {

         div_package.innerHTML = data.toString();
     })
 }


 window.addEventListener('message', (msg) => {
     // 监听子窗口发送过来的消息
     console.log('message=', msg.data);
     div_package.innerHTML = msg.data.toString();
 })

ipcRenderer.on('autoUpdater', (event, args) => {
    console.log('ipcRenderer==> autoUpdater', args)
})

 const myNotification = new Notification('Title', {
    body: 'Notification from the Renderer process'
  })
  
  myNotification.onclick = () => {
    console.log('Notification clicked')
  }